FIG. 1 is a schematic diagram of an existing storage architecture and a synchronization manner thereof, where a master module is configured to process external write requests and read requests, a slave module is configured to receive synchronous data update from the master module, and the slave module can only process external read requests. As shown in FIG. 1, a synchronization principle of this synchronization manner is as follows: a service is deployed in multiple parts, that is, one master module and multiple slave modules; when external write requests are sent to the master module, each time an external write request arrives, the master module records a digit sequence, where the digit sequence increases progressively in order as the number of write requests increases; the master module synchronizes write operations to the slave modules according to the order of digits in the digit sequences; when receiving the write operation sent from the master module, each slave module updates local data, and records a digit sequence of the local data; and when the digit sequence of the master module is the same as that of the slave module, it indicates that data of the slave module is latest data. A basic idea of this synchronization manner is synchronizing each write operation to the slave module, to ensure that data of the slave module can be updated in real time and is the same as that of the master module.
However, this synchronization manner is designed for relatively simple storage models, for example, one-level storage and multi-level non-associative storage. However, this synchronization manner is not applicable to a multi-level associative storage architecture (shown in FIG. 2) used by some companies (for example, Tencent) at present.
In the storage architecture used at present, data is stored in solid-state disk (SSD) files and a write buffer is added above the SSD files according to an implementation principle of an SSD, so as to improve write performance of the SSD and prolong the service life of the SSD as much as possible. In the storage architecture shown in FIG. 2, a storage location of data in the SSD file determines a storage location offset of the data in the write buffer, and storage locations of data in the write buffer need to be one-to-one corresponding to storage locations in the SSD files.
If the synchronization manner shown in FIG. 1 is applied to the storage architecture shown in FIG. 2, the following problems may arise:
(1) Problem of data consistency: According to this synchronization manner, after the master module synchronizes the write operation to the slave module according to the order of digits in the digit sequence, the slave module writes data into the write buffer first, and flushes all data in the write buffer to SSD files when a data amount in the write buffer reaches a regulated threshold. During this process, it is hard to ensure that when the slave module writes data into the write buffer, a relative location of each piece of data in the write buffer of the slave module is the same as that in the write buffer of the master module; besides, when the slave module flushes the data from the write buffer to the SSD files, it is also hard to ensure that storage locations of data blocks flushed to the SSD files are the same as storage locations in the SSD files of the master module; if any of the storage locations of the data in the write buffer or in the SSD files of the slave module is not the same as a corresponding storage location of the data in the write buffer or in the SSD files of the master module, the data becomes invalid data that cannot be read by a user.
(2) Problem of design complexity: If the problem of data accuracy in (1) needs to be solved, the design of synchronization logic may become quite complex.